package br.com.vti.sisp_sicrim.antigo.controller.relatorios;

import java.io.FileNotFoundException;
import java.text.ParseException;
import java.util.Arrays;

import net.sf.jasperreports.engine.JRException;
import br.com.caelum.vraptor.Result;
import br.com.vti.sisp_sicrim.antigo.util.Relatorios;
import br.com.vti.sisp_sicrim.antigo.util.Sessao;

/**
 * Classe responsavel por encapsular o tratamento e as consistencias da tela
 * Idcte102Report
 * 
 * @author Incode - Data: jun/2014
 * 
 */
public class Idcte102Report {
	private String nom1;
	private String nom3;
	private String nom2;
	private String nom4;
	private String f1;
	private String f4;
	private String f2;
	private String f5;
	private String f3;
	private String f6;
	private long[] regger = new long[3];
	private int[] datn = new int[3];
	private String[] comun = new String[3];
	private int[] datnas = new int[3];
	private String[] docum1 = new String[3];
	private String[] docum2 = new String[3];
	private String[] pis = new String[3];
	private String[] numcpf = new String[3];
	private long[] pispas = new long[3];
	private String[] numpos = new String[3];
	private String[] numvia = new String[3];
	private Result result;
	private Sessao sessao;
	private Relatorios report; // Classes views

	// Classes includes
	public Idcte102Report() throws JRException {
		inicializar();
	}

	public Idcte102Report(Sessao sessao) throws JRException {
		this.sessao = sessao;
		inicializar();
	}

	public void inicializar() throws JRException {
		report = new Relatorios();
		Arrays.fill(regger, 0);
		Arrays.fill(datn, 0);
		nom1 = "";
		nom3 = "";
		nom2 = "";
		nom4 = "";
		f1 = "";
		f4 = "";
		f2 = "";
		f5 = "";
		f3 = "";
		f6 = "";
		Arrays.fill(comun, "");
		Arrays.fill(datnas, 0);
		Arrays.fill(docum1, "");
		Arrays.fill(docum2, "");
		Arrays.fill(pis, "");
		Arrays.fill(numcpf, "");
		Arrays.fill(pispas, 0);
		Arrays.fill(numpos, "");
		Arrays.fill(numvia, "");
		report.setNumeroRel(1, "D");
		{
			report.setNumeroLinhaRel(2, 4);
			{
				report.adicionaCampo(8, 13, "Regger[1]", "N", "ZZZ999999999-9", "");
				report.adicionaCampo(28, 8, "Datn[1]", "N", "99/99/9999", "");
				report.adicionaCampo(48, 13, "Regger[2]", "N", "ZZZ999999999-9", "");
				report.adicionaCampo(68, 8, "Datn[2]", "N", "99/99/9999", "");
				report.setFimLinhaRel();
			}
			report.setNumeroLinhaRel(3, 2);
			{
				report.adicionaCampo(3, 35, "Nom1", "X", "", "");
				report.adicionaCampo(44, 35, "Nom3", "X", "", "");
				report.setFimLinhaRel();
			}
			report.setNumeroLinhaRel(4, 2);
			{
				report.adicionaCampo(3, 35, "Nom2", "X", "", "");
				report.adicionaCampo(44, 35, "Nom4", "X", "", "");
				report.setFimLinhaRel();
			}
			report.setNumeroLinhaRel(6, 2);
			{
				report.adicionaCampo(3, 35, "F1", "X", "", "");
				report.adicionaCampo(44, 35, "F4", "X", "", "");
				report.setFimLinhaRel();
			}
			report.setNumeroLinhaRel(7, 2);
			{
				report.adicionaCampo(3, 35, "F2", "X", "", "");
				report.adicionaCampo(44, 35, "F5", "X", "", "");
				report.setFimLinhaRel();
			}
			report.setNumeroLinhaRel(8, 2);
			{
				report.adicionaCampo(3, 35, "F3", "X", "", "");
				report.adicionaCampo(44, 35, "F6", "X", "", "");
				report.setFimLinhaRel();
			}
			report.setNumeroLinhaRel(9, 4);
			{
				report.adicionaCampo(3, 24, "Comun[1]", "X", "", "");
				report.adicionaCampo(28, 8, "Datnas[1]", "N", "99/99/9999", "");
				report.adicionaCampo(44, 24, "Comun[2]", "X", "", "");
				report.adicionaCampo(69, 8, "Datnas[2]", "N", "99/99/9999", "");
				report.setFimLinhaRel();
			}
			report.setNumeroLinhaRel(11, 2);
			{
				report.adicionaCampo(3, 35, "Docum1[1]", "X", "", "");
				report.adicionaCampo(44, 35, "Docum1[2]", "X", "", "");
				report.setFimLinhaRel();
			}
			report.setNumeroLinhaRel(12, 4);
			{
				report.adicionaCampo(3, 20, "Docum2[1]", "X", "", "");
				report.adicionaCampo(29, 9, "Pis[1]", "X", "", "");
				report.adicionaCampo(44, 20, "Docum2[2]", "X", "", "");
				report.adicionaCampo(69, 9, "Pis[2]", "X", "", "");
				report.setFimLinhaRel();
			}
			report.setNumeroLinhaRel(13, 4);
			{
				report.adicionaCampo(3, 11, "Numcpf[1]", "X", "XXXXXXXXX-XX", "");
				report.adicionaCampo(27, 13, "Pispas[1]", "N", "ZZZZZZZZZZZ", "");
				report.adicionaCampo(44, 11, "Numcpf[2]", "X", "XXXXXXXXX-XX", "");
				report.adicionaCampo(67, 13, "Pispas[2]", "N", "ZZZZZZZZZZZ", "");
				report.setFimLinhaRel();
			}
			report.setNumeroLinhaRel(14, 4);
			{
				report.adicionaCampo(3, 5, "Numpos[1]", "X", "", "");
				report.adicionaCampo(31, 6, "Numvia[1]", "X", "", "");
				report.adicionaCampo(44, 5, "Numpos[2]", "X", "", "");
				report.adicionaCampo(72, 6, "Numvia[2]", "X", "", "");
				report.setFimLinhaRel();
			}
			report.setNumeroLinhaRel(18, 1);
			{
				report.adicionaCampo(1, 1, "lit_1_1", "C", "", ".");
				report.setFimLinhaRel();
			}
		}
	}

	public boolean validar() {
		// validar os campos recebidos da tela
		return true;
	}

	public String getNom1() {
		return nom1;
	}

	public void setNom1(String nom1) throws ParseException {
		this.nom1 = nom1;
		report.adicionaValorReport("Nom1", nom1);
	}

	public String getNom3() {
		return nom3;
	}

	public void setNom3(String nom3) throws ParseException {
		this.nom3 = nom3;
		report.adicionaValorReport("Nom3", nom3);
	}

	public String getNom2() {
		return nom2;
	}

	public void setNom2(String nom2) throws ParseException {
		this.nom2 = nom2;
		report.adicionaValorReport("Nom2", nom2);
	}

	public String getNom4() {
		return nom4;
	}

	public void setNom4(String nom4) throws ParseException {
		this.nom4 = nom4;
		report.adicionaValorReport("Nom4", nom4);
	}

	public String getF1() {
		return f1;
	}

	public void setF1(String f1) throws ParseException {
		this.f1 = f1;
		report.adicionaValorReport("F1", f1);
	}

	public String getF4() {
		return f4;
	}

	public void setF4(String f4) throws ParseException {
		this.f4 = f4;
		report.adicionaValorReport("F4", f4);
	}

	public String getF2() {
		return f2;
	}

	public void setF2(String f2) throws ParseException {
		this.f2 = f2;
		report.adicionaValorReport("F2", f2);
	}

	public String getF5() {
		return f5;
	}

	public void setF5(String f5) throws ParseException {
		this.f5 = f5;
		report.adicionaValorReport("F5", f5);
	}

	public String getF3() {
		return f3;
	}

	public void setF3(String f3) throws ParseException {
		this.f3 = f3;
		report.adicionaValorReport("F3", f3);
	}

	public String getF6() {
		return f6;
	}

	public void setF6(String f6) throws ParseException {
		this.f6 = f6;
		report.adicionaValorReport("F6", f6);
	}

	public long[] getRegger() {
		return regger;
	}

	public void setRegger(long[] regger) throws ParseException {
		this.regger = regger;
		report.adicionaValorReport("Regger", regger);
	}

	public int[] getDatn() {
		return datn;
	}

	public void setDatn(int[] datn) throws ParseException {
		this.datn = datn;
		report.adicionaValorReport("Datn", datn);
	}

	public String[] getComun() {
		return comun;
	}

	public void setComun(String[] comun) throws ParseException {
		this.comun = comun;
		report.adicionaValorReport("Comun", comun);
	}

	public int[] getDatnas() {
		return datnas;
	}

	public void setDatnas(int[] datnas) throws ParseException {
		this.datnas = datnas;
		report.adicionaValorReport("Datnas", datnas);
	}

	public String[] getDocum1() {
		return docum1;
	}

	public void setDocum1(String[] docum1) throws ParseException {
		this.docum1 = docum1;
		report.adicionaValorReport("Docum1", docum1);
	}

	public String[] getDocum2() {
		return docum2;
	}

	public void setDocum2(String[] docum2) throws ParseException {
		this.docum2 = docum2;
		report.adicionaValorReport("Docum2", docum2);
	}

	public String[] getPis() {
		return pis;
	}

	public void setPis(String[] pis) throws ParseException {
		this.pis = pis;
		report.adicionaValorReport("Pis", pis);
	}

	public String[] getNumcpf() {
		return numcpf;
	}

	public void setNumcpf(String[] numcpf) throws ParseException {
		this.numcpf = numcpf;
		report.adicionaValorReport("Numcpf", numcpf);
	}

	public long[] getPispas() {
		return pispas;
	}

	public void setPispas(long[] pispas) throws ParseException {
		this.pispas = pispas;
		report.adicionaValorReport("Pispas", pispas);
	}

	public String[] getNumpos() {
		return numpos;
	}

	public void setNumpos(String[] numpos) throws ParseException {
		this.numpos = numpos;
		report.adicionaValorReport("Numpos", numpos);
	}

	public String[] getNumvia() {
		return numvia;
	}

	public void setNumvia(String[] numvia) throws ParseException {
		this.numvia = numvia;
		report.adicionaValorReport("Numvia", numvia);
	}

	public long getRegger(int index) {
		return regger[index];
	}

	public void setRegger(int index, long regger) throws ParseException {
		this.regger[index] = regger;
		report.adicionaValorReport("Regger"+"["+String.valueOf(index)+"]", regger);
	}

	public int getDatn(int index) {
		return datn[index];
	}

	public void setDatn(int index, int datn) throws ParseException {
		this.datn[index] = datn;
		report.adicionaValorReport("Datn"+"["+String.valueOf(index)+"]", datn);
	}

	public String getComun(int index) {
		return comun[index];
	}

	public void setComun(int index, String comun) throws ParseException {
		this.comun[index] = comun;
		report.adicionaValorReport("Comun"+"["+String.valueOf(index)+"]", comun);
	}

	public int getDatnas(int index) {
		return datnas[index];
	}

	public void setDatnas(int index, int datnas) throws ParseException {
		this.datnas[index] = datnas;
		report.adicionaValorReport("Datnas"+"["+String.valueOf(index)+"]", datnas);
	}

	public String getDocum1(int index) {
		return docum1[index];
	}

	public void setDocum1(int index, String docum1) throws ParseException {
		this.docum1[index] = docum1;
		report.adicionaValorReport("Docum1"+"["+String.valueOf(index)+"]", docum1);
	}

	public String getDocum2(int index) {
		return docum2[index];
	}

	public void setDocum2(int index, String docum2) throws ParseException {
		this.docum2[index] = docum2;
		report.adicionaValorReport("Docum2"+"["+String.valueOf(index)+"]", docum2);
	}

	public String getPis(int index) {
		return pis[index];
	}

	public void setPis(int index, String pis) throws ParseException {
		this.pis[index] = pis;
		report.adicionaValorReport("Pis"+"["+String.valueOf(index)+"]", pis);
	}

	public String getNumcpf(int index) {
		return numcpf[index];
	}

	public void setNumcpf(int index, String numcpf) throws ParseException {
		this.numcpf[index] = numcpf;
		report.adicionaValorReport("Numcpf"+"["+String.valueOf(index)+"]", numcpf);
	}

	public long getPispas(int index) {
		return pispas[index];
	}

	public void setPispas(int index, long pispas) throws ParseException {
		this.pispas[index] = pispas;
		report.adicionaValorReport("Pispas"+"["+String.valueOf(index)+"]", pispas);
	}

	public String getNumpos(int index) {
		return numpos[index];
	}

	public void setNumpos(int index, String numpos) throws ParseException {
		this.numpos[index] = numpos;
		report.adicionaValorReport("Numpos"+"["+String.valueOf(index)+"]", numpos);
	}

	public String getNumvia(int index) {
		return numvia[index];
	}

	public void setNumvia(int index, String numvia) throws ParseException {
		this.numvia[index] = numvia;
		report.adicionaValorReport("Numvia"+"["+String.valueOf(index)+"]", numvia);
	}

	public void setPageSize(int pagesize) throws JRException {
		report.setPageSize(pagesize);
	}

	public void setLineSize(int linesize) {
		report.setLineSize(linesize);
	}

	public int getPageSize() {
		return report.getPageSize();
	}

	public int getPageLine() {
		return report.getPageLine();
	}

	public void saltaLinhas(int qtdLinhas) throws ParseException, JRException {
		report.saltaLinhas(qtdLinhas);
	}

	public void gravaRelatorio(int nroRel) throws ParseException, JRException {
		report.gravaRelatorio(report, nroRel, false);
	}

	public void imprimir() throws FileNotFoundException, JRException {
		report.imprimir();
	}
}
